﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace QSMonitor
{
    public partial class frmMain : Form
    {
        public frmMain()
        {
            InitializeComponent();
            MenuStrip ms = new MenuStrip();
            ToolStripMenuItem function = new ToolStripMenuItem("Function");
            ToolStripMenuItem exit = new ToolStripMenuItem("Exit", null, new EventHandler(menuClick));
            ms.Items.Add(exit);
            ms.Items.Add(function);
            ToolStripMenuItem qs = new ToolStripMenuItem("QS", null, new EventHandler(menuClick));
            qs.Tag = "QSMonitor.Form1";
            ((ToolStripDropDownMenu)(function.DropDown)).ShowImageMargin = false;
            function.DropDownItems.Add(qs);

            ToolStripMenuItem rate = new ToolStripMenuItem("Rate", null, new EventHandler(menuClick));
            rate.Tag = "QSMonitor.frmRate";
            function.DropDownItems.Add(rate);

            rate = new ToolStripMenuItem("TWMRate", null, new EventHandler(menuClick));
            rate.Tag = "QSMonitor.frmTWM";
            function.DropDownItems.Add(rate);

            Controls.Add(ms);
        }

        void menuClick(object sender, EventArgs e)
        {
            ToolStripMenuItem item = sender as ToolStripMenuItem;
            if (item.Text.Equals("Exit"))
            {
                Application.Exit();
            }
            else
            {
                Form frm = System.Activator.CreateInstance(Type.GetType(
                    item.Tag.ToString())) as Form;
                frm.MdiParent = this;
                frm.Show();
            }
            
        }



    }
}
